<template>
  <router-view/>
</template>

<script>
// @ is an alias to /src
import { defineComponent, reactive, ref } from "vue";
import { useRouter } from "vue-router";
import { Toast } from "vant";
import { useStore } from "vuex";
export default defineComponent({
  name: "Index",

  created() {
    //session 中取 用户信息
    this.state.userInfo = JSON.parse(localStorage.getItem("userInfo"));
    if (this.state.userInfo) {
      //环信登录
      this.initWebIM();
    } else {
    }
  },

  setup() {
    //实例化store
    const store = useStore();
    //实例化路由
    const router = useRouter();

    //下拉刷新 状态
    const state = reactive({
      login: false,
      userInfo: {},
      onLine:true
    });

    // 使用 mutation
    const initWebIM = () => {
      store.commit("initWebIM", {
        userName: "hx" + state.userInfo.docId,
        passWord: "111111",
      });
    };


    
    return {
      state,
      initWebIM,
    };
  },
});
</script>



<style lang="less">
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}

#nav {
  padding: 30px;

  a {
    font-weight: bold;
    color: #2c3e50;

    &.router-link-exact-active {
      color: #42b983;
    }
  }
}
</style>
